home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / vidhrdw / ssi.c < prev    next >
C/C++ Source or Header  |  2000-04-04  |  2KB  |  125 lines

  1. #include "driver.h"
  2. #include "vidhrdw/generic.h"
  3. #include "cpu/m68000/m68000.h"
  4.  
  5.  
  6.  
  7.  
  8. READ_HANDLER( ssi_videoram_r )
  9. {
  10.     return READ_WORD(&videoram[offset]);
  11. }
  12.  
  13. WRITE_HANDLER( ssi_videoram_w )
  14. {
  15.     COMBINE_WORD_MEM(&videoram[offset],data);
  16. }
  17.  
  18. int ssi_vh_start(void)
  19. {
  20.     return 0;
  21. }
  22.  
  23. void ssi_vh_stop (void)
  24. {
  25. }
  26.  
  27. void ssi_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
  28. {
  29.     int i,x,y,offs,code,color,spritecont,flipx,flipy;
  30.     int xcurrent,ycurrent;
  31.  
  32.  
  33.     /* update the palette usage */
  34.     {
  35.         unsigned short palette_map[256];
  36.  
  37.         memset (palette_map, 0, sizeof (palette_map));
  38.  
  39.         color = 0;
  40.  
  41.         for (offs = 0;offs < 0x3400;offs += 16)
  42.         {
  43.             spritecont = (READ_WORD(&videoram[offs+8]) & 0xff00) >> 8;
  44.  
  45.             if ((spritecont & 0x04) == 0)
  46.             {
  47.                 color = READ_WORD(&videoram[offs+8]) & 0x00ff;
  48.             }
  49.  
  50.             code = READ_WORD(&videoram[offs]) & 0x1fff;
  51.  
  52.             palette_map[color] |= Machine->gfx[0]->pen_usage[code];
  53.         }
  54.  
  55.         for (i = 0;i < 256;i++)
  56.         {
  57.             int usage = palette_map[i];
  58.             int j;
  59.  
  60.             if (usage)
  61.             {
  62.                 palette_used_colors[i * 16 + 0] = PALETTE_COLOR_TRANSPARENT;
  63.                 for (j = 1; j < 16; j++)
  64.                     if (palette_map[i] & (1 << j))
  65.                         palette_used_colors[i * 16 + j] = PALETTE_COLOR_USED;
  66.                     else
  67.                         palette_used_colors[i * 16 + j] = PALETTE_COLOR_UNUSED;
  68.             }
  69.             else
  70.                 memset(&palette_used_colors[i * 16],PALETTE_COLOR_UNUSED,16);
  71.         }
  72.  
  73.         palette_recalc ();
  74.     }
  75.  
  76.     osd_clearbitmap(bitmap);
  77.     x = 0;
  78.     y = 0;
  79.     xcurrent = 0;
  80.     ycurrent = 0;
  81.     color = 0;
  82.  
  83.     for (offs = 0;offs < 0x3400;offs += 16)
  84.     {
  85.         spritecont = (READ_WORD(&videoram[offs+8]) & 0xff00) >> 8;
  86.  
  87.         flipx = spritecont & 0x01;
  88.         flipy = spritecont & 0x02;
  89.  
  90.         if ((spritecont & 0x04) == 0)
  91.         {
  92.             x = READ_WORD(&videoram[offs+4]) & 0x0fff;
  93.             if (x >= 0x800) x -= 0x1000;
  94.             xcurrent = x;
  95.  
  96.             y = READ_WORD(&videoram[offs+6]) & 0x0fff;
  97.             if (y >= 0x800) y -= 0x1000;
  98.             ycurrent = y;
  99.  
  100.             color = READ_WORD(&videoram[offs+8]) & 0x00ff;
  101.         }
  102.         else
  103.         {
  104.             if ((spritecont & 0x10) == 0)
  105.                 y = ycurrent;
  106.             else if ((spritecont & 0x20) != 0)
  107.                 y += 16;
  108.  
  109.             if ((spritecont & 0x40) == 0)
  110.                 x = xcurrent;
  111.             else if ((spritecont & 0x80) != 0)
  112.                 x += 16;
  113.         }
  114.  
  115.         code = READ_WORD(&videoram[offs]) & 0x1fff;
  116.  
  117.         drawgfx(bitmap,Machine->gfx[0],
  118.                 code,
  119.                 color,
  120.                 flipx,flipy,
  121.                 x,y,
  122.                 &Machine->drv->visible_area,TRANSPARENCY_PEN,0);
  123.     }
  124. }
  125.